package com.example.designpatterns.Strategy.Cash;

/**
 * @author HUAWEI
 * 策略上下文
 */
public class CashContext {
    private CashSuper cashSuper;
    public CashContext(int discountType) {
        switch (discountType) {
            case 1:
                cashSuper = new CashRebate(0.7);
                break;
            case 2:
                cashSuper = new CashRebate(0.8);
                break;
            case 3:
                cashSuper = new CashReturn(300, 50);
                break;
            case 4:
                cashSuper = new CashReturn(200, 20);
                break;
            default:
                cashSuper = new CashNormal();
        }
    }

    public double getResult(double price, double num){
        return cashSuper.acceptCash(price, num);
    }
}
